import React, { Component } from 'react';
import { Form,Input} from 'antd';
import './modal.css';
import PropTypes from 'prop-types';

class EditWellForm extends Component {

  static propTypes = {  
    drillId: PropTypes.string.isRequired,        
    drillAddress: PropTypes.string.isRequired,
    drillContact: PropTypes.string.isRequired,
    drillRemark: PropTypes.string.isRequired,
    setForm: PropTypes.func.isRequired
  }

  formRef = React.createRef();

  componentDidMount() {
    this.props.setForm(this.formRef);
  }
  render() {
    const layout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 15 },   
    };
    const {drillId,drillAddress,drillContact,drillRemark} = this.props;       
    return (
      <div>
        <Form 
          {...layout} 
          ref={this.formRef}   //可以通过ref获取数据域
          name="control-ref" 
          onFinish={this.onFinish}
          initialValues={{
            drill_id: drillId,
            drill_address: drillAddress,
            drill_contact: drillContact,
            drill_remark: drillRemark,
          }}
        >
          <Form.Item 
            name="drill_id" 
            label="测井编号" 
            rules={[ { required: true,message:'不能为空！' } ]}
          >
            <Input placeholder="请输入测井编号" disabled/>   
          </Form.Item>

          <Form.Item 
            name="drill_address" 
            label="测井地址" 
            rules={[ { required: true,message:'不能为空！' } ]}
          >
            <Input placeholder="请输入测井地址"/>  
          </Form.Item>
          <Form.Item 
            name="drill_contact" 
            label="联系电话" 
            rules={[ { required: true,message:'不能为空！' } ]}
          >
            <Input placeholder="请输入联系电话"/> 
          </Form.Item>
          <Form.Item name="drill_remark" label="备注">
            <Input.TextArea />
          </Form.Item>
        </Form>
      </div>  
    )
  }
}   

export default EditWellForm;